<?php

	/**
	 * @see Bike_Js_VarPart_Object
	 */
	require_once 'Bike/Js/VarPart/Object.php';


	abstract class Bike_Js_Ext extends Bike_Js_VarPart_Object implements Bike_Js_Interface_Resource
	{
		static protected $_initObject = True;

		static protected $_tooltipType = 'qtip';
		static protected $_inputElSuffix = '-inputEl';
		static protected $_resourcePath = 'extjs/';
		static protected $_version = '4.0';
		static protected $_resourceIncluded = False;

		protected $_part = 'Ext';

		static public function setTooltipType($TooltipType)
		{			self::$_tooltipType = $TooltipType;
		}

		static public function getTooltipType()
		{
			return self::$_tooltipType;
		}

		static public function setInputElSuffix($InputElSuffix)
		{
			self::$_inputElSuffix = $InputElSuffix;
		}

		static public function getInputElSuffix()
		{
			return self::$_inputElSuffix;
		}

		static public function setVersion($Version)
		{
			self::$_version = $Version;
		}

		static public function getVersion()
		{
			return self::$_version;
		}

		static public function setResourcePath($resourcePath)
		{
			self::$_resourcePath = $resourcePath;
		}

		static public function getResourcePath()
		{
			return self::$_resourcePath;
		}

		static public function setResourceIncluded($resourceIncluded = True)
		{
			self::$_resourceIncluded = (bool) $resourceIncluded;
		}

		static public function isResourceIncluded()
		{
			return self::$_resourceIncluded;
		}

		static public function includeResource(Zend_View_Interface $view)
		{
			if(!self::isResourceIncluded())
			{

				$view->headLink()->prependStylesheet(self::getResourceFilePath($view, '/resources/css/ext-all.css'));

				$view->headScript()->prependFile(self::getResourceFilePath($view, '/locale/ext-lang-'.$view->language()->getLocale().'.js'));
				$view->headScript()->prependFile(self::getResourceFilePath($view, '/ext-all.js'));
				self::setResourceIncluded();
			}
		}

		static public function getResourceFullPath()
		{
			return self::getResourcePath().self::getVersion();
		}

		static public function getResourceFilePath(Zend_View_Interface $view, $file)
		{
			return $view->filePath(self::getResourceFullPath().$file, 'resource');
		}

		protected function processSetListeners($listeners)
		{
			if(is_array($listeners))
			{
				$listeners = array_merge((array) $this->listeners, $listeners);
			}
			return $listeners;
		}
	}
